//package com.letoken.platform.repo.app.manager;
//
//import com.letoken.platform.repo.app.dao.UserAddressMapper;
//import lombok.extern.log4j.Log4j2;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//
///**
// * @author letokenlabs
// * @date 2022/11/15$
// */
//@Log4j2
//@Repository
//public class AppUserAddressManager {
//
//    @Resource
//    private UserAddressMapper userAddressMapper;
//
//
//    //@Value("${dex.wallet.aes.secret}")
//    private String dexAesSecret;
//
//
//    /**
//     * 根据id查询用户平台钱包地址
//     *
//     * @param addressId
//     * @return
//     */
////
////    public String queryWalletByUserId(Integer userId) {
////        Object address = AppWalletAddresRedis.me().getValue(userId.toString());
////        if (StringUtils.isEmpty(address)) {
////            QueryWrapper<AppUserAddress> query = new QueryWrapper<>();
////            query.eq("user_id", userId);
////            AppUserAddress item = appUserAddressMapper.selectOne(query);
////            if (item != null) {
////                address = item.getWalletAddress();
////                AppWalletAddresRedis.me().put(userId.toString(), address.toString());
////            }
////        }
////        return address == null ? null : address.toString();
////    }
//
//    /**
//     * 根据钱包地址或用户id获取
//     * @param userAddressOrUserId
//     * @return
//     */
////    public AppUserAddress queryWalletAddressByAddressOrId(String userAddressOrUserId) {
////        AppUserAddress userAddress;
////        LambdaQueryWrapper<AppUserAddress> queryWrapper = Wrappers.lambdaQuery();
////        queryWrapper.eq(AppUserAddress::getWalletAddress,userAddressOrUserId);
////        userAddress = appUserAddressMapper.selectOne(queryWrapper);
////        if (userAddress == null){
////            queryWrapper = Wrappers.lambdaQuery();
////            queryWrapper.eq(AppUserAddress::getUserId,userAddressOrUserId);
////            userAddress = appUserAddressMapper.selectOne(queryWrapper);
////        }
////        return userAddress;
////    }
////
////    public AppUserAddress queryByAddressId(Integer addressId) {
////        return appUserAddressMapper.selectById(addressId);
////    }
////
////    /**
////     * 根据钱包地址获取
////     * @param userAddress
////     * @return
////     */
////    public AppUserAddress queryWalletAddressByAddress(String userAddress) {
////        LambdaQueryWrapper<AppUserAddress> queryWrapper = Wrappers.lambdaQuery();
////        Object userId = AppWalletUserRedis.me().getValue(userAddress);
////        if (!StringUtils.isEmpty(userId)) {
////            queryWrapper.eq(AppUserAddress::getUserId, userId);
////        }
////        else {
////            queryWrapper.eq(AppUserAddress::getWalletAddress, userAddress);
////        }
////        return appUserAddressMapper.selectOne(queryWrapper);
////    }
////
////    /**
////     * 判断充值地址是否存在
////     * @param userAddress
////     * @return
////     */
////    public boolean isAddressExists(String userAddress) {
////        // 判断缓存
////        Object userId = AppWalletUserRedis.me().getValue(userAddress);
////        if (!StringUtils.isEmpty(userId)) {
////            return true;
////        }
////        // 查询数据库
////        LambdaQueryWrapper<AppUserAddress> queryWrapper = Wrappers.lambdaQuery();
////        queryWrapper.eq(AppUserAddress::getWalletAddress, userAddress);
////        AppUserAddress appUserAddress = appUserAddressMapper.selectOne(queryWrapper);
////        if (appUserAddress != null) {
////            userId = appUserAddress.getUserId();
////            AppWalletUserRedis.me().put(userAddress, userId.toString());
////        }
////        return appUserAddress != null;
////    }
//}
